package com.base.object.each;

public class Each03 {
    public static void main(String[] args) {
        EachUser eachUser01 = new EachUser(1,"A") ;
        EachUser eachUser02 = new EachUser(1,"B") ;
        System.out.println(eachUser01.equals(eachUser02));
    }
}
class EachUser {
    private Integer cardId ;
    private String name ;

    public EachUser(Integer cardId, String name) {
        this.cardId = cardId;
        this.name = name;
    }

    @Override
    public int hashCode() {
        return cardId.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj != null){
            EachUser compareObj = (EachUser)obj ;
            return this.cardId.intValue()==compareObj.cardId ;
        }
        return Boolean.FALSE ;
    }

    @Override
    public String toString() {
        return "EachUser{" +"cardId=" + cardId +", name='" + name +'}';
    }

    public Integer getCardId() {
        return cardId;
    }

    public void setCardId(Integer cardId) {
        this.cardId = cardId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}